<template>
	<view class="luckDrawDetails">
		<view class="back" style="background-image: url('../../../static/luckDraw/details/bgtop.png');">
			<image class="back-img" @click="back" src="../../../static/index/fanhui.png" mode=""></image>
			<text class="back-name">幸运大抽奖</text>
		</view>
		<view class="content" style="background-image: url('../../../static/luckDraw/details/bg.png');">
			<view class="top-roulette" style="background-image: url('../../../static/luckDraw/details/toplunpan.png');">
				<view class="top-roulette-box" @click="checkJackpot">
					查看奖池
				</view>
			</view>
			<view class="lottery" style="background-image: url('../../../static/luckDraw/details/zhanpan.png');">
				<image src="../../../static/luckDraw/details/jiantou.png" mode="" @click="zhuanpan"></image>
			</view>
			<view class="integralNum">
				<view class="integralNum-left">
					抽奖消耗200积分
				</view>
				<view class="integralNum-right">
					现有3000积分
				</view>
			</view>
			<view class="rule">
				<view class="rule-left" @click="record">
					<image class="rule-img" src="../../../static/luckDraw/details/zhongjiang.png" mode=""></image>
					<text>中奖记录</text>
				</view>
				<view class="rule-right" @click="rule">
					<image class="rule-img" src="../../../static/luckDraw/details/rule.png" mode=""></image>
					<text>活动规则</text>
				</view>
			</view>
			<view class="progress">
				<text>今日还差3次必中奖品</text>
				<u-line-progress height="14" style="width: 440rpx;" active-color='#FF7200' :percent="70" :show-percent="false"></u-line-progress>
			</view>
			<view class="notice" style="background-image: url('../../../static/luckDraw/kuang.png');">
				<view class="notice-box" style="background-image: url('../../../static/luckDraw/yuan.png');">
					中奖大公告
				</view>
				<image class="laba-img" src="../../../static/luckDraw/laba.png" mode=""></image>
				<view class="notice-information">
					<view class="home">
						<view class="list uni-flex uni-column">
							<view class="wrap-item">
								<view class="lis uni-flex uni-column" :animation="animationData">
									<view class="uni-flex uni-column" v-for="(item, index) in list" :key="index">
										<view class="swiper-item item_title uni-flex list_item">
											<view class="userlistmsg">
												<image class="userlistmsg-img" :src="item.url" mode=""></image>
												<view>{{ item.text }}</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 规则 -->
		<u-popup :show="show" v-model="show" mode="bottom" :round="true" borderRadius="20">
			<view style="width: 100%;height: 876rpx;background: #FFFFFF;padding: 40rpx;position: relative;">
				<view class="pop-title">
					抽奖规则
				</view>
				<view class="pop-content" v-for="(item,index) in ruleList" :key='index'>
					<view class="pop-content-title">
						{{item.title}}
					</view>
					<view class="pop-content-text">
						{{item.content}}
					</view>
				</view>
				<view class="sure-btn" @click="show=false">
					确定
				</view>
			</view>
		</u-popup>
		<!-- 抽奖弹框 -->
		<u-popup :show="isshow" v-model="isshow" mode="center" :round="true" borderRadius="20" v-if="num==0">
			<view style="width: 670rpx;height: auto;padding: 40rpx 0 0;">
				<view class="pop-title">
					恭喜您成功抽中奖品
				</view>
				<view class="pop-content2">
					<view class="pop-content-text2" style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
						<image src="../../../static/healthy/anmoyi.png" mode=""></image>
						<view style="font-size: 28rpx;font-weight: 400;color: #333333;width: 400rpx;">
							Apple iPhone 13 128GB 蓝色
							支持移动联通电信5G 双卡...
						</view>
					</view>
				</view>
				<view  @click="show=false" style="border-top: 1px solid #F2F2F2;height: 60rpx;width: 670rpx;display: flex;padding-bottom: 20rpx;">
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #FF7200;border-right: 2rpx solid #f2f2f2;">分享好友赚积分</text>
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #999999;">确定</text>
				</view>
			</view>
		</u-popup>
		<u-popup :show="isshow" v-model="isshow" mode="center" :round="true" borderRadius="20" v-if="num==1">
			<view style="width: 670rpx;height: auto;padding: 40rpx 0 0;">
				<view class="failed">
					<view class="failed-title">
						很遗憾，您没有中奖
					</view>
					<view class="failed-title2">
						今日在参与3次抽奖必中奖品
					</view>
				</view>
				<view style="border-top: 1px solid #F2F2F2;height: 60rpx;width: 670rpx;display: flex;padding-bottom: 20rpx;">
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #FF7200;border-right: 2rpx solid #f2f2f2;">继续抽奖</text>
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #999999;">确定</text>
				</view>
			</view>
		</u-popup>
		<u-popup :show="isshow" v-model="isshow" mode="center" :round="true" borderRadius="20" closeable=true v-if="num==2">
			<view style="width: 670rpx;height: auto;padding: 40rpx 0 0;">
				<view class="failed">
					<view class="failed-title">
						恭喜您抽中积分奖励
					</view>
					<view class="failed-title2">
						观看视频即可获取积分20-50积分
					</view>
				</view>
				<view style="height: 80rpx;border-top: 1px solid #F2F2F2;display: flex;justify-content: center;align-items: center;font-size: 36rpx;font-weight: 400;color: #FF0000;">
					 观看视频
				</view>
			</view>
		</u-popup>
		<u-popup :show="isshow" v-model="isshow" mode="center" :round="true" borderRadius="20" v-if="num==3">
			<view style="width: 670rpx;height: auto;padding: 40rpx 0 0;">
				<view style="font-size: 36rpx;font-weight: 400;color: #333333;margin: 30rpx 0;display: flex;justify-content: center;align-items: center;">
					很遗憾，您没有中奖
				</view>
				<view style="border-top: 1px solid #F2F2F2;height: 60rpx;width: 670rpx;display: flex;padding-bottom: 20rpx;">
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #FF7200;border-right: 2rpx solid #f2f2f2;">继续抽奖</text>
					<text style="flex: 1;height:100%; display:flex; justify-content: center;align-items: center;font-size: 36rpx;color: #999999;">确定</text>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num:0,
				isshow: false, //抽奖弹框
				ruleList: [{
						title: '产品质量',
						content: '我们严格控制产品的质量，为用户朋友，们提供最优质的产品和最高效的服务'
					}, {
						title: '产品质量 ',
						content: '我们严格控制产品的质量,为用户朋友们提供最优质的产品和最高效的服务'
					},
					{
						title: '产品质量 ',
						content: '我们严格控制产品的质量， 为用户朋友们提供最优质的产品和最高效的服务'
					}
				],
				list: [{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},
					{
						url: '../../../static/luckDraw/header.png',
						text: '恭喜用户***抽中一等奖小汽车一辆'
					},

				],
				scrollHeight: 0, //向上滚动距离
				height: 0, //.lis高度（滚动框高度）
				animationData: {}, //动画对像
				show: false, //规则弹框
			}
		},
		mounted() {
			// console.log("11")
			this.prizeScroll();
		},
		methods: {
			//转盘箭头
			zhuanpan() {
				this.isshow = true
			},
			//查看奖池
			checkJackpot() {
				uni.navigateTo({
					url: '/myPackageA/luckDraw/luckDrawdetails/checkJackpot'
				})
			},
			//规则
			rule() {
				this.show = true
			},
			//中奖纪录
			record() {
				uni.navigateTo({
					url: '/myPackageA/luckDraw/luckDrawdetails/record'
				})
			},
			back() {
				uni.navigateBack()
			},
			getHeight(Class) {
				let query = uni.createSelectorQuery().in(this);
				query
					.selectAll(Class)
					.boundingClientRect(data => {
						this.height = data[0].height;
					})
					.exec();
			},
			prizeScroll() {
				let speed = 50;
				let animation = uni.createAnimation({
					duration: this.getHeight('.lis') / speed,
					timingFunction: 'linear',
					delay: 0
				});
				this.animation = animation;
				setInterval(() => {
					if (this.scrollHeight >= this.height) {
						animation.translateY(0).step();
						this.scrollHeight = 0;
						this.animationData = animation.export();
					} else {
						this.scrollHeight = this.scrollHeight + 1;
						animation.translateY(-this.scrollHeight).step();
						this.animationData = animation.export();
					}
				}, speed);
			}
		}
	}
</script>

<style scoped lang="less">
	.failed{
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		.failed-title{
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #333333;
		}
		.failed-title2{
			margin: 60rpx;
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			line-height: 44rpx;
			color: #333333;
		}
	}
	.sure-btn2 {
		display: flex;
		height: 80rpx;
		border-top:1px solid #F2F2F2;
		text:first-child {
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FF7200;
			flex: 1;
			border-right: 1rpx solid #F2F2F2;
		}

		text:last-child {
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			flex: 1;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FF0000;
		}
	}

	.pop-content2 {
		padding: 0rpx 150rpx 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;

		image {
			width: 318rpx;
			height: 228rpx;
		}

	}

	.pop-content {
		.pop-content-title {
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #333333;
		}

		.pop-content-text {
			// text-indent: 2em;
			padding-left: 20rpx;
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #999999;
			margin: 40rpx 0;
		}
	}

	.pop-title {
		text-align: center;
		margin-bottom: 40rpx;
		padding-top: 56rpx;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #333333;
	}

	.sure-btn {
		position: absolute;
		bottom: 10rpx;
		// left: 2%;
		width: 90%;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		background: linear-gradient(163deg, #FF7200 0%, #EF130B 100%);
		opacity: 1;
		border-radius: 30rpx;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
	}

	.home,
	.list {
		width: 100%;
		padding-top: 30upx;
		height: 100%;
		overflow: hidden;
	}

	.userlistmsg {
		width: 100%;
		display: flex;
		justify-content: space-around;
		color: #FFFFFF;
		padding: 10rpx 0;
		font-size: 26rpx;

		.userlistmsg-img {
			width: 47rpx;
			height: 47rpx;
			border-radius: 50%;
		}
	}

	.notice {
		height: 590rpx;
		width: 90%;
		margin: 100rpx 40rpx 5% 5%;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		position: relative;
		display: flex;

		.laba-img {
			width: 37rpx;
			height: 37rpx;
			margin: 90rpx 0 0 50rpx;
		}

		.notice-information {
			flex: 1;
			height: 80%;
			margin-top: 66rpx;
			margin-right: 20px;
		}

		.notice-box {
			width: 209rpx;
			height: 89rpx;
			background-repeat: no-repeat;
			background-size: 100% 100%;
			font-size: 30rpx;
			line-height: 89rpx;
			text-align: center;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #FFFFFF;
			position: absolute;
			top: -14px;
			left: 0;
			right: 0;
			margin: 0 auto;
		}
	}

	.badge-box {
		margin-right: 8rpx;
		width: 26rpx;
		height: 26rpx;
		background: #FFA100;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;

		.badge-img {
			width: 16rpx;
			height: 16rpx;
		}
	}

	.progress {
		margin-top: 95rpx;

		text {
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFEFE;
			margin-bottom: 22rpx;
		}
	}

	.rule-img {
		width: 70rpx;
		height: 70rpx;
		margin-bottom: 20rpx;
	}

	.content {
		background-size: 100% 100%;
		background-repeat: no-repeat;
		width: 100%;
		height: 100%;
		padding: 0 40rpx;
		padding-top: 200rpx;

		.rule {
			margin-top: 55rpx;
			display: flex;
			width: 100%;
			justify-content: space-between;

			.rule-left {
				display: flex;
				align-items: center;
				flex-direction: column;
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFFFFF;
			}

			.rule-right {
				display: flex;
				align-items: center;
				flex-direction: column;
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFFFFF;
			}
		}

		.integralNum {
			width: 100%;
			border-radius: 37rpx;
			height: 70rpx;
			justify-content: center;
			align-items: center;
			border: 6rpx solid #ffe185;
			margin-top: 83rpx;
			display: flex;
			color: #FFFFFF;
			font-size: 36rpx;

			.integralNum-left {
				text-align: center;
				flex: 1;
				height: 100%;
				border-right: 6rpx solid #ffe185;
				background: #fd811f;
				border-radius: 37rpx 0 0 37rpx;
			}

			.integralNum-right {
				flex: 1;
				height: 100%;
				text-align: center;
				background-color: #FD1F1F;
				border-radius: 0rpx 37rpx 37rpx 0rpx;
			}
		}

		.lottery {
			width: 100%;
			height: 856rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
			position: relative;

			image {
				width: 138rpx;
				height: 135rpx;
				position: absolute;
				top: 206rpx;
				left: 0;
				right: 0;
				margin: auto;
			}
		}

		.top-roulette {
			width: 100%;
			height: 476rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
			margin-bottom: 51rpx;

			.top-roulette-box {
				width: 120rpx;
				height: 40rpx;
				line-height: 40rpx;
				text-align: center;
				background: #FF7200;
				border-radius: 10rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFFEFE;
			}
		}
	}

	.luckDrawDetails {
		width: 100%;
		height: auto;
		position: relative;
		// padding-bottom: 40rpx;
	}

	.back {
		position: fixed;
		top: 0;
		left: 0;
		padding-top: 80rpx;
		width: 100%;
		height: 176rpx;
		display: flex;
		align-self: center;
		padding-left: 0 !important;
		padding-right: 0 !important;
		background-size: 100% 100%;
		background-repeat: no-repeat;

		.back-img {
			width: 40rpx;
			height: 40rpx;
			margin-top: 10rpx;
			margin-left: 50rpx;
		}

		.back-name {
			flex: 1;
			font-size: 18px;
			line-height: 31px;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			text-align: center;
		}
	}
</style>
